Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eligibility API logic #286

Merged
merged 56 commits into from
Jul 18, 2024
Merged

Eligibility API logic #286

merged 56 commits into from
Jul 18, 2024

Conversation

richherrera
Copy link
Contributor

@richherrera richherrera commented Jul 15, 2024

Reason for changes

DTMOBILES-777

  • Add the necessary logic to make the request to the Eligibility API GraphQL. With the eligibility checks, the merchant will be able to see if the Venmo flow is eligible or not.

Summary of changes

  • Add Eligibility Response model
  • Add Client and API logic
  • Add docstrings
  • Add UTs
  • Add demo functionality

Simulator Screen Recording - iPhone 15 Pro Max - 2024-07-17 at 13 37 50

Checklist

  • Added a changelog entry

Authors

@@ -0,0 +1,7 @@
import Foundation

enum SupportedPaymentMethodsType: String {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this enum based on the logic that was previously removed:

@richherrera richherrera marked this pull request as ready for review July 15, 2024 22:50
Base automatically changed from fix-venmo-feature-merge to venmo-feature July 16, 2024 14:18
Copy link
Collaborator

@sshropshire sshropshire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Sources/CorePayments/Eligibility/EligibilityResponse.swift Outdated Show resolved Hide resolved
Comment on lines 42 to 43
let paypal: SupportedPaymentMethodsTypeEligibility
let paylater: SupportedPaymentMethodsTypeEligibility
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let paypal: SupportedPaymentMethodsTypeEligibility
let paylater: SupportedPaymentMethodsTypeEligibility
let payPal: SupportedPaymentMethodsTypeEligibility
let payLater: SupportedPaymentMethodsTypeEligibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated: cd016e3

}
do {
let config = try await configManager.getCoreConfig()
let eligibilityRequest = EligibilityRequest(currencyCode: "USD", intent: .CAPTURE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take it or leave it - maybe we want to leave a TODO for this, but this intent will have to be the same intent used to create the orderID which will eventually get used when constructing a VenmoCheckoutRequest(orderID: "<ORDER_ID>")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've updated it by adding the intent as a parameter and making changes to the UI: 8f253cf](8f253cf)


extension EligibilityAPI {

static let rawQuery = """
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really need this to be in an extension here. Was there a particular reason for using it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to put the query in an extension to make the code more readable. I based it on this implementation where the query is in the same method, which makes the method much larger. Basically, it's to separate(ish) responsibilities

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also throw it in a private method under check if we want to separate it but move it out of the extension

@@ -1,9 +1,36 @@
import Foundation

/// The `EligibilityClient` class provides methods to check eligibility status based on provided requests.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 Nice docstrings

@@ -0,0 +1,10 @@
import Foundation

public enum EligibilityIntent: String {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I wonder if we only support CAPTURE and AUTHORIZE. Per these PP docs, these are the only 2 you can create an orderID with.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be OK to just start with those 2. Also needs a docstring since public

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 docs says SALE and AUTHORIZE, thanks for your feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, I also changed cases to lowercase to be more Swifty: 54e53c0

Copy link
Collaborator

@agedd agedd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very clean docstrings - lgtm!! 🚀


let configManager = CoreConfigManager(domain: "Venmo Payments")

@Published var state = VenmoState()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take it our leave it for this PR, but we started a transition to use a new CurrentState enum across all of the views vs individualized views with custom states. If you take a look at the PayPal Web Payments views you can see where that was in motion. Not a blocker, would just be nice to eventually share duplicated states with a shared interface. Can totally be a follow up or something we tackle when we address the other view since only PayPal Web was updated thus far.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks for your feedback: 33d3d46

@@ -570,31 +581,27 @@
path = Models;
sourceTree = "<group>";
};
62D3FB122C3DB4B30046563B /* VenmoPaymentsTests */ = {
459633142C46BD51002008EF /* Recovered References */ = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we can remove these Recovered References?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, updated: f9f2df3

PayPal.xcodeproj/project.pbxproj Outdated Show resolved Hide resolved

extension EligibilityAPI {

static let rawQuery = """
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also throw it in a private method under check if we want to separate it but move it out of the extension

}

var asResult: EligibilityResult {
.init(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.init(
EligibilityResult(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: 644df70

@@ -0,0 +1,7 @@
import Foundation

enum SupportedPaymentMethodsType: String {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to lowercase these as well or keep as is since it's internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!!! Done: b422115

@richherrera richherrera merged commit c281aa9 into venmo-feature Jul 18, 2024
5 checks passed
@richherrera richherrera deleted the eligibility-logic-request branch July 18, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants